﻿
CREATE  Function f_CurrDerogAuto(@LoanID int)
RETURNS bit WITH SCHEMABINDING BEGIN

DECLARE @Ret int,@Trade float

SELECT @Ret = count(*) FROM dbo.v_TradeReferences
WHERE LoanID = @LoanID AND
			Status > 1 AND
			(AccountState = 1) AND
			IsAuto = 1

RETURN  ISNULL(@Ret,0)
END















